import request from "@/utils/request.js";

/**
 * 获取登录验证码
 */
export const getLoginCode = function() {
	return request.get("user/loginCode", null, {
		noAuth: true,
		noVerify: true
	}, "arraybuffer");
}

/**
 * 邮箱登录
 * @param {Object} data
 */
export const emailToLogin = function(data) {
	return request.post("user/login", data, {
		noAuth: true
	});
}

/**
 * 获取用户信息
 */
export const getUserInfo = function(data = {}) {
	return request.get("user/info", data);
}

/**
 * 获取邮箱验证码
 */
export const getEmailCode = function(data) {
	return request.post("user/emailCode", data, {
		noAuth: true
	})
}

/**
 * 邮箱注册用户
 */
export const regByEmail = function(data) {
	return request.post("user/reg/email", data, {
		noAuth: true
	});
}

/**
 * 获取用户收藏
 */
export const getUserCollect = function(data) {
	return request.get("user/collect", data);
}

/**
 * 获取用户点赞
 */
export const getUserLike = function(data) {
	return request.get("user/like", data);
}

/**
 * 修改用户信息
 */
export const editUserInfo = function(data) {
	return request.post('user/edit', data);
}

/**
 * 退出登录
 */
export const logout = function() {
	return request.post("user/logout");
}

/**
 * 更换密码
 */
export const changePassword = function(data) {
	return request.post(
		'user/changePassword',
		data,
		{noAuth: true}
	)
}

/**
 * 关注与取消关注用户
 * @param {Object} data
 */
export const attentionUser = function(data) {
	return request.post('user/attention', data);
}